<template>
  <div>
    <h3>mitt通讯实例</h3>
    <BrotherVue></BrotherVue>
    <LittleBrotherVue></LittleBrotherVue>
  </div>
</template>

<script lang="ts">
import bus from '@/libs/bus'
import { defineComponent, onBeforeUnmount } from 'vue'
import BrotherVue from './Brother.vue';
import LittleBrotherVue from './LittleBrother.vue';

export default defineComponent({
  components: {
    BrotherVue,
    LittleBrotherVue
  },
  setup() {
    const sayHi = (msg: unknown | string = 'hello world!'): void => {
      console.log(msg);
    }

    bus.on('sayHi', sayHi)

    onBeforeUnmount(() => {
      bus.off('sayHi', sayHi)
    })


    return {}
  }
})
</script>

<style scoped>

</style>
